# -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
from djtools.middleware.threadlocals import ThreadLocals

tl = ThreadLocals()

class StatusCompromisso(models.Model):
    descricao = models.CharField(max_length=15, unique=True)
    
    class Meta:
        ordering = ['descricao']
        verbose_name=u'Status do Compromisso'
        verbose_name_plural=u'Status dos Compromissos'

    def __unicode__(self):
        return '%s' %(self.descricao)

class Compromisso(models.Model):
#    usuario = models.ForeignKey(User, editable=False, default=tl.get_current_user)
    usuario = models.ForeignKey(User, editable=False, null=True, blank=True)
    data = models.DateField()
    hora = models.TimeField()
    atividade = models.TextField(null=True, blank=True)
    assunto = models.TextField(null=True, blank=True)
    providencia = models.TextField(verbose_name=u'Provicência', null=True, blank=True)
    status = models.ForeignKey(StatusCompromisso)
    
    class Meta():
        ordering = ['status', 'data']
        verbose_name = u'Compromisso'
        verbose_name_plural = u'Compromissos'